﻿
/**
*备案
*/
Chenxin.UI.ChangeMarkedForm = Chenxin.extend(Chenxin.UI.FormCommon, {
    actionUrl: 'service/markedHandler.ashx',
    id: 'changeRecordWin',
    renderTo: 'jqm_changerecord',
    saveSucc: function() {
        _this.scope.grid.reload();
    },
    createForm: function() {
        return Chenxin.FormCommon.ChangeMarkedForm('changeMarked');
    },
    initFormValidator: function() {
        _this = this;
        //$.formValidator.initConfig({ validatorgroup: this.id, formid: "form_1", onerror: function(msg) { alert(msg) }, onsuccess: function() { return true; } });
        $("#changPersonCode").formValidator({ validatorgroup: this.id, onshow: "请输入工号", onfocus: "输入工号", oncorrect: " " }).inputValidator({ //数字验证
            min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "" }, onerror: ""
        }).ajaxValidator({
            url: "service/markedHandler.ashx",
            datatype: "json",
            data: "op=validateperson",
            success: function(data) {
                if (data.data.model) {
                    $('#MarkPerson').val(data.data.model.UserName);
                    $('#MarkDepart').val(data.data.model.DepartName);
                    return true;
                } else {
                    return false;
                }
            },
            buttons: $("#changeMarked_Save"),
            error: function() { alert("服务器没有返回数据，可能服务器忙，请重试"); },
            onerror: "员工号不存在",
            onwait: "正在校验，请稍候..."
        });
        //        $("#MarkCode").formValidator({ validatorgroup: this.id, onshow: "请输备案号", onfocus: "请输备案号", oncorrect: " " }).inputValidator({
        //            min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "" }, onerror: "备案号不能为空!"
        //        }).functionValidator({ //数字验证
        //            fun: function(val, elem) { return val.isNum(); }, onerror: "请输入数字"
        //        }).ajaxValidator({
        //            url: "service/markedHandler.ashx",
        //            datatype: "json",
        //            data: "op=validatemarked&recordid=" + _this.currentId,
        //            success: function(data) {
        //                if (data.success == 0) {
        //                    return false;
        //                } else {
        //                    return true;
        //                }
        //            },
        //            buttons: $("#changeMarked_Save"),
        //            error: function() { alert("服务器没有返回数据，可能服务器忙，请重试"); },
        //            onerror: "备案号已存在！",
        //            onwait: "正在校验，请稍候..."
        //        });
        $("#MarkCode").formValidator({ validatorgroup: this.id, onshow: "请输备案号", onfocus: "请输备案号", oncorrect: " " }).inputValidator({
            min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "" }, onerror: "备案号不能为空!"
        }).functionValidator({ //数字验证
            fun: function(val, elem) {
                if (!val.isNum())
                    return '请输入数字';
                //进行AJAX验证-
                var _data = { exist: true };
                Chenxin.ajax({
                    type: "get",
                    dataType: "json",
                    async: false,
                    url: _this.actionUrl,
                    data: { op: 'validatemarked', MarkCode: val, recordid: _this.currentId },
                    onSuccess: function(data) {
                        _data = data;
                    }
                });
                if (_data.exist) {
                    return false;
                } else {
                    return true;
                }
            },
            onerror: "备案号已存在"
        });
    },
    initEvent: function() {
        var _this = this;
        $('#changeMarked_Save').live('click', function() {
            _this.op = "edit";
            _this.save();
        });
        $('#changeMarked_Cancle').live('click', function() {
            _this.hide();
        });
    },
    initComponent: function() {
        Chenxin.UI.ChangeMarkedForm.superclass.initComponent.call(this);
    }
});
 Chenxin.FormCommon.ChangeMarkedForm=function(comboIdPrefix){
 return '<table class="tbl_f jqTabWh"><tbody> <tr><th style="width:120px; height:25px;">房源编号：</th><td style="width:500px;" ><input type="text" name="HouseCode" readonly="readonly" class="inputbox_n"/></td></tr><tr><th style="width:100px; height:25px;">地址：</th><td><input type="text" name="Address" readonly="readonly" class="inputbox_n"/></td></tr><tr><th style="width:100px; height:25px;">所属人员：</th> <td><input type="text" name="AddPerson" class="inputbox_n" readonly="readonly" /></td></tr><tr><th style="width:100px; height:25px;">所属门店：</th> <td><input type="text" name="AddDepart" class="inputbox_n" readonly="readonly" /></td></tr><tr><th>备案号：</th><td ><div style="float:left"><input name="MarkCode" id="MarkCode"  maxlength="20" class="inputbox_n" type="text" /></div><div style="float:left" id="MarkCodeTip"/></td></tr><tr><th style="width:100px; height:25px;">产权证号：</th> <td style=" width:440px;"><div style="float:left"><input name="PropertyCode" class="inputbox_n" id ="PropertyCode" maxlength="20" type="text"/></div><div style="float:left" id="PropertyCodeTip"></td><tr><th style="width:100px; height:25px;">产权人名：</th> <td style=" width:440px;"><div style="float:left"><input name="PropertyPersonName"  class="inputbox_n" id ="PropertyPersonName" maxlength="20" type="text"/></div><div style="float:left" id="PropertyPersonNameTip"></td></tr><tr><th>变更工号：</th><td ><div style="float:left"><input  name="changPersonCode" id="changPersonCode"  maxlength="20" class="inputbox_n" type="text" /></div><div style="float:left" id="changPersonCodeTip"/></td></tr><tr><th>姓名：</th><td><input name="MarkPerson" class="inputbox_n" readonly="readonly" type="text" id ="MarkPerson" /></td></tr><tr><th>门店：</th> <td><input readonly="readonly" class="inputbox_n" type="text" id ="MarkDepart" name="MarkDepart" /></td></tr><tr> <td colspan="3" align="right"><div style="float:right;"><input type="button" id="' + comboIdPrefix + '_Save"  class="btn_n_2"  value="提交" />&nbsp<a style="float:right;" id="' + comboIdPrefix + '_Cancle" class="btn_n fl" href="#"><span>取消</span></a></div></td></tr></tbody> </table>';
}